package com.ycsj.goldmedalnewconcept.teacher.fragment;

import android.graphics.Color;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.blankj.utilcode.util.ToastUtils;
import com.github.mikephil.charting.charts.BarChart;
import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.AxisBase;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.formatter.IAxisValueFormatter;
import com.ycsj.common.base.BaseApplication;
import com.ycsj.common.base.BaseLazyFragment;
import com.ycsj.common.manager.BqaManager;
import com.ycsj.common.manager.PickerManager;
import com.ycsj.common.mapchart.BarChartManager;
import com.ycsj.common.mapchart.LineChartManager;
import com.ycsj.common.utils.DateUtils;
import com.ycsj.common.utils.GsonUtil;
import com.ycsj.goldmedalnewconcept.R;
import com.ycsj.goldmedalnewconcept.common.Constants;
import com.ycsj.goldmedalnewconcept.common.HttpAddress;
import com.ycsj.goldmedalnewconcept.common.http.HttpUtils;
import com.ycsj.goldmedalnewconcept.common.util.AccountUtils;
import com.ycsj.goldmedalnewconcept.teacher.bean.ClassAnalyInfo;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import okhttp3.Call;

/**
 * 班级分析
 * Created by Administrator on 2018/7/2 0002.
 */

public class TeacherClassAnalyFragment extends BaseLazyFragment implements View.OnClickListener {

    //柱状图
    private BarChart barChart;

    //迟到,请假,旷课的曲线图
    private LineChart lineChart_cd, lineChart_qj, lineChart_kd;

    //加载框
    private RelativeLayout rlLoading;

    //内容视图
    private RelativeLayout rlContent;

    //起始时间
    private TextView tvBeginTime, tvEndTime;

    //展示柱状图说明的文字
    private TextView tvBar;

    //选择的开始时间和结束
    private String begindate, enddate;

    //班级号
    private String classNum;

    public static final String TAG = TeacherClassAnalyFragment.class.getName();

    //Y轴上的最大值,标签个数
    private int yMax = 10, yLableCount = 10;

    //请求的参数
    private String acc, role, apptoken;

    //单例模式
    private static class LazyHolder {
        private static final TeacherClassAnalyFragment INSTANCE = new TeacherClassAnalyFragment();
    }

    public static final TeacherClassAnalyFragment newInstance(String classNum) {
        TeacherClassAnalyFragment teacherClassAnalyFragment = TeacherClassAnalyFragment.LazyHolder.INSTANCE;
        Bundle bundle = new Bundle();
        bundle.putString("classnum", classNum);
        teacherClassAnalyFragment.setArguments(bundle);
        return teacherClassAnalyFragment;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.teacher_fragment_class_analy;
    }

    @Override
    public void lazyInit(View view, Bundle savedInstanceState) {

        // 初始化视图
        initView(view);

        //获取班级号
        initIntent();

        //设置初始化时间
        initDate();

        //初始化请求参数
        initParams();

        //请求服务器
        http(BqaManager.NORML);
    }


    /**
     * 初始化请求参数
     */
    private void initParams() {
        acc = AccountUtils.getAccount(getContext());
        role = AccountUtils.getRole(getContext());
        apptoken = AccountUtils.getToken(getContext());
    }


    /**
     * 初始化视图
     *
     * @param view
     */
    private void initView(View view) {

        rlLoading = view.findViewById(R.id.rl_loading);
        rlContent = view.findViewById(R.id.rl_conent);
        barChart = view.findViewById(R.id.barChart);
        rlContent.setVisibility(View.GONE);
        rlLoading.setVisibility(View.VISIBLE);

        tvBeginTime = view.findViewById(R.id.tv_begin);
        tvEndTime = view.findViewById(R.id.tv_end_time);

        tvBeginTime.setOnClickListener(this);
        tvEndTime.setOnClickListener(this);

        tvBar = view.findViewById(R.id.tv_bar_date);

        //迟到的曲线图
        lineChart_cd = view.findViewById(R.id.line_cd);

        //请假的曲线图
        lineChart_qj = view.findViewById(R.id.line_qj);

        //旷到的曲线图
        lineChart_kd = view.findViewById(R.id.line_kd);
    }


    /**
     * 获取班级号
     */
    private void initIntent() {
        classNum = getArguments().getString("classnum");
    }


    /**
     * 设置初始化时间
     */
    private void initDate() {
        enddate = DateUtils.getTime(new Date(), "yyyy-MM-dd");
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Calendar c = Calendar.getInstance();
        c.setTime(new Date());
        c.add(Calendar.MONTH, -2);
        Date m = c.getTime();
        begindate = format.format(m);

        //设置初始时间
        tvBeginTime.setText(DateUtils.getFmTime(begindate));
        tvEndTime.setText(DateUtils.getFmTime(enddate));

        //设置初始的柱状图的文字说明
        tvBar.setText(getMonth(begindate) + "~" + getMonth(enddate) + "月份考勤数据汇总");
    }

    /**
     * 请求服务器获取数据
     *
     * @param method
     */
    private void http(final int method) {
        Map<String, String> map = new HashMap<>();
        map.put("type", "8");
        map.put("acc", acc);
        map.put("role", role);
        map.put("classnum", classNum);
        map.put("begindate", begindate);
        map.put("enddate", enddate);
        map.put("apptoken", apptoken);
        map.put("platform", "2");

        HttpUtils.post(HttpAddress.CLASSANALY, map, this, new HttpUtils.CallBack() {
            @Override
            public void onError(Call call, Exception e, int id) {
                if (rlLoading != null && rlLoading.getVisibility() == View.VISIBLE) {
                    rlLoading.setVisibility(View.GONE);
                }
                ToastUtils.showShort(BaseApplication.ERROR);
            }

            @Override
            public void onResponse(String response, int id) {
                if (rlLoading != null && rlLoading.getVisibility() == View.VISIBLE) {
                    rlLoading.setVisibility(View.GONE);
                }
                if (rlContent != null && rlContent.getVisibility() != View.VISIBLE) {
                    rlContent.setVisibility(View.VISIBLE);
                }

                if (!TextUtils.isEmpty(response)) {
                    ClassAnalyInfo info = null;
                    try {
                        if (method == BqaManager.NORML) {
                            info = GsonUtil.jsonToBean(response, ClassAnalyInfo.class);
                        } else {
                            info = GsonUtil.jsonToBean(response, ClassAnalyInfo.class);
                        }

                    } catch (Exception e) {
                        Log.i("test", Constants.PARSEDATAERROR);
                    }

                    if (null != info) {
                        if ("200".equals(info.getState())) {
                            List<ClassAnalyInfo.DataBean> newDatas = info.getData();
                            if (newDatas != null) {
                                if (method == BqaManager.NORML) {

                                    //设置柱状图图标数据
                                    setBarChartData(newDatas);

                                    //设置迟到的曲线图数据
                                    setLineChartAbsentData(newDatas);

                                    //设置请假的曲线图数据
                                    setLineChartRestData(newDatas);

                                    //设置旷到的曲线图数据
                                    setLineChartLateData(newDatas);

                                } else {

                                    //更新柱状图图标数据
                                    updateBarChartData(newDatas);

                                    //更新迟到的曲线图数据
                                    updateLineChartAbsentData(newDatas);

                                    //更新请假的曲线图数据
                                    updateChartRestData(newDatas);

                                    //更新旷到的曲线图数据
                                    updateChartLateData(newDatas);
                                }
                            }
                        } else {
                            ToastUtils.showShort(Constants.ERRORSTATE + info.getState());
                            Log.i("test", Constants.ERRORSTATE + info.getState());
                        }
                    } else {
                        Log.i("test", Constants.EMPTY);
                    }
                } else {
                    Log.i("test", Constants.ERROR);
                }
            }
        });
    }

    /**
     * 设置柱状图的数据
     *
     * @param newDatas
     */
    private void setBarChartData(List<ClassAnalyInfo.DataBean> newDatas) {

        BarChartManager barChartManager = new BarChartManager(barChart, getContext());

        //设置X轴上的显示数据
        ArrayList<Float> xValues = new ArrayList<>();
        for (int i = 0; i < newDatas.size(); i++) {
            //解析时间获取月份
            String date = newDatas.get(i).getDate();//返回的是2018-06

            if (!TextUtils.isEmpty(getMonth(date))) {
                xValues.add(Float.parseFloat(getMonth(date)));
            }
        }


        //设置X轴上的数据格式,返回几月
        XAxis xAxis = barChart.getXAxis();

        xAxis.setValueFormatter(new IAxisValueFormatter() {
            @Override
            public String getFormattedValue(float value, AxisBase axis) {
                int index = (int) value;
                String begin = getMonth(begindate);
                int beginTime = Integer.valueOf(begin);
                int res = index + beginTime;
                if (res > 12) {
                    return (res - 12) + "月";
                } else {
                    return res + "月";
                }
            }
        });


        //设置多条柱状图y轴
        List<List<Float>> yValues = new ArrayList<>();
        //迟到数据
        List<Float> lateValues = new ArrayList<>();
        //请假数据
        List<Float> restValues = new ArrayList<>();
        //旷到数据
        List<Float> absentValues = new ArrayList<>();
        for (int i = 0; i < newDatas.size(); i++) {
            absentValues.add(Float.parseFloat(newDatas.get(i).getAbsent()));
            restValues.add(Float.parseFloat(newDatas.get(i).getRest()));
            lateValues.add(Float.parseFloat(newDatas.get(i).getLate()));
        }
        //添加迟到数据
        yValues.add(lateValues);

        //添加请假数据
        yValues.add(restValues);

        //添加旷到数据
        yValues.add(absentValues);

        //颜色集合
        List<Integer> colours = new ArrayList<>();
        colours.add(getContext().getResources().getColor(R.color.teacher_absent));
        colours.add(getContext().getResources().getColor(R.color.teacher_rest));
        colours.add(getContext().getResources().getColor(R.color.teacher_late));


        //线的名字集合
        List<String> names = new ArrayList<>();
        names.add("迟到");
        names.add("请假");
        names.add("旷到");

        //显示多条柱状图
        barChartManager.showBarChart(xValues, yValues, names, colours);

        barChartManager.setDescription("考勤汇总表");

        //设置X轴最大值,最小值,标签数量
        barChartManager.setXAxis(newDatas.size(), 0f, newDatas.size());

        //设置Y轴最大值,最小值,标签数量
        barChartManager.setYAxis(yMax, 0, yLableCount);

    }

    /**
     * 更新柱状图的数据
     *
     * @param newDatas
     */
    private void updateBarChartData(List<ClassAnalyInfo.DataBean> newDatas) {

        setBarChartData(newDatas);

        //重新绘制
        barChart.invalidate();

    }


    /**
     * 设置迟到的曲线图数据
     *
     * @param newDatas
     */
    private void setLineChartAbsentData(List<ClassAnalyInfo.DataBean> newDatas) {

        //获取服务器返回的所有月份
        final List<String> months = new ArrayList<>();
        for (int i = 0; i < newDatas.size(); i++) {
            months.add(getMonth(newDatas.get(i).getDate()));
        }

        LineChartManager lineChartManager = new LineChartManager(lineChart_cd);

        //设置X轴上的显示数据
        List<Float> absentXValues = new ArrayList<>();
        for (int i = 1; i <= newDatas.size(); i++) {
            absentXValues.add((float) i);
        }

        XAxis xAxis = lineChart_cd.getXAxis();

        xAxis.setValueFormatter(new IAxisValueFormatter() {
            @Override
            public String getFormattedValue(float value, AxisBase axis) {
                int index = (int) value;
                String res = "";
                //index的值取1到absentXValues.size,最大6个月
                if (months.size() == 6) {
                    if (index == 1 || index == 2 || index == 3 || index == 4 || index == 5 || index == 6) {
                        res = (Integer.valueOf(months.get(index - 1))) + "月";
                    }
                } else if (months.size() == 5) {
                    if (index == 1 || index == 2 || index == 3 || index == 4 || index == 5) {
                        res = (Integer.valueOf(months.get(index - 1))) + "月";
                    }
                } else if (months.size() == 4) {
                    if (index == 1 || index == 2 || index == 3 || index == 4) {
                        res = (Integer.valueOf(months.get(index - 1))) + "月";
                    }
                } else if (months.size() == 3) {
                    if (index == 1 || index == 2 || index == 3) {
                        res = (Integer.valueOf(months.get(index - 1))) + "月";
                    }
                } else if (months.size() == 2) {
                    if (index == 1 || index == 2) {
                        res = (Integer.valueOf(months.get(index - 1))) + "月";
                    }
                } else if (months.size() == 1) {
                    if (index == 1) {
                        res = (Integer.valueOf(months.get(index - 1))) + "月";
                    }
                }
                return res;
            }
        });

        //设置y轴的数据
        List<List<Float>> yValues = new ArrayList<>();
        List<Float> absentValues = new ArrayList<>();
        for (int i = 0; i < newDatas.size(); i++) {
            absentValues.add(Float.parseFloat(newDatas.get(i).getLate()));
        }
        yValues.add(absentValues);

        //颜色
        List<Integer> colours = new ArrayList<>();
        colours.add(Color.GREEN);

        //线的名字集合
        List<String> names = new ArrayList<>();
        names.add("迟到");

        //创建一条折线的图表
        lineChartManager.showLineChart(absentXValues, yValues.get(0), names.get(0), colours.get(0));

        //设置X轴最大值,最小值,标签数量
        lineChartManager.setXAxis(absentXValues.size(), 1f, absentXValues.size());

        lineChartManager.setDescription("");

        //设置Y轴最大值,最小值,标签数量
        lineChartManager.setYAxis(yMax, 0, yLableCount);
    }

    /**
     * 更新迟到的曲线图数据
     *
     * @param newDatas
     */
    private void updateLineChartAbsentData(List<ClassAnalyInfo.DataBean> newDatas) {
        setLineChartAbsentData(newDatas);
        lineChart_cd.invalidate();
    }


    /**
     * 设置请假的曲线图数据
     *
     * @param newDatas
     */
    private void setLineChartRestData(List<ClassAnalyInfo.DataBean> newDatas) {
        //获取服务器返回的所有月份
        final List<String> months = new ArrayList<>();
        for (int i = 0; i < newDatas.size(); i++) {
            months.add(getMonth(newDatas.get(i).getDate()));
        }

        LineChartManager lineChartManager = new LineChartManager(lineChart_qj);

        //设置X轴上的显示数据
        List<Float> resetXValues = new ArrayList<>();
        for (int i = 1; i <= newDatas.size(); i++) {
            resetXValues.add((float) i);
        }

        XAxis xAxis = lineChart_qj.getXAxis();

        xAxis.setValueFormatter(new IAxisValueFormatter() {
            @Override
            public String getFormattedValue(float value, AxisBase axis) {
                int index = (int) value;
                String res = "";
                //index的值取1到absentXValues.size,最大6个月
                if (months.size() == 6) {
                    if (index == 1 || index == 2 || index == 3 || index == 4 || index == 5 || index == 6) {
                        res = (Integer.valueOf(months.get(index - 1))) + "月";
                    }
                } else if (months.size() == 5) {
                    if (index == 1 || index == 2 || index == 3 || index == 4 || index == 5) {
                        res = (Integer.valueOf(months.get(index - 1))) + "月";
                    }
                } else if (months.size() == 4) {
                    if (index == 1 || index == 2 || index == 3 || index == 4) {
                        res = (Integer.valueOf(months.get(index - 1))) + "月";
                    }
                } else if (months.size() == 3) {
                    if (index == 1 || index == 2 || index == 3) {
                        res = (Integer.valueOf(months.get(index - 1))) + "月";
                    }
                } else if (months.size() == 2) {
                    if (index == 1 || index == 2) {
                        res = (Integer.valueOf(months.get(index - 1))) + "月";
                    }
                } else if (months.size() == 1) {
                    if (index == 1) {
                        res = (Integer.valueOf(months.get(index - 1))) + "月";
                    }
                }
                return res;
            }
        });

        //设置y轴的数据
        List<List<Float>> yValues = new ArrayList<>();
        List<Float> resetValues = new ArrayList<>();
        for (int i = 0; i < newDatas.size(); i++) {
            resetValues.add(Float.parseFloat(newDatas.get(i).getRest()));
        }
        yValues.add(resetValues);

        //颜色
        List<Integer> colours = new ArrayList<>();
        colours.add(Color.GREEN);

        //线的名字集合
        List<String> names = new ArrayList<>();
        names.add("请假");

        //创建一条折线的图表
        lineChartManager.showLineChart(resetXValues, yValues.get(0), names.get(0), colours.get(0));

        //设置X轴最大值,最小值,标签数量
        lineChartManager.setXAxis(resetXValues.size(), 1f, resetXValues.size());

        lineChartManager.setDescription("");

        //设置Y轴最大值,最小值,标签数量
        lineChartManager.setYAxis(yMax, 0, yLableCount);
    }

    /**
     * 更新请假的曲线图数据
     *
     * @param newDatas
     */
    private void updateChartRestData(List<ClassAnalyInfo.DataBean> newDatas) {
        setLineChartRestData(newDatas);
        lineChart_qj.invalidate();
    }


    /**
     * 设置旷到的曲线图数据
     *
     * @param newDatas
     */
    private void setLineChartLateData(List<ClassAnalyInfo.DataBean> newDatas) {
        //获取服务器返回的所有月份
        final List<String> months = new ArrayList<>();
        for (int i = 0; i < newDatas.size(); i++) {
            months.add(getMonth(newDatas.get(i).getDate()));
        }

        LineChartManager lineChartManager = new LineChartManager(lineChart_kd);

        //设置X轴上的显示数据
        List<Float> lateXValues = new ArrayList<>();
        for (int i = 1; i <= newDatas.size(); i++) {
            lateXValues.add((float) i);
        }

        XAxis xAxis = lineChart_kd.getXAxis();

        xAxis.setValueFormatter(new IAxisValueFormatter() {
            @Override
            public String getFormattedValue(float value, AxisBase axis) {
                int index = (int) value;
                String res = "";
                //index的值取1到absentXValues.size,最大6个月
                if (months.size() == 6) {
                    if (index == 1 || index == 2 || index == 3 || index == 4 || index == 5 || index == 6) {
                        res = (Integer.valueOf(months.get(index - 1))) + "月";
                    }
                } else if (months.size() == 5) {
                    if (index == 1 || index == 2 || index == 3 || index == 4 || index == 5) {
                        res = (Integer.valueOf(months.get(index - 1))) + "月";
                    }
                } else if (months.size() == 4) {
                    if (index == 1 || index == 2 || index == 3 || index == 4) {
                        res = (Integer.valueOf(months.get(index - 1))) + "月";
                    }
                } else if (months.size() == 3) {
                    if (index == 1 || index == 2 || index == 3) {
                        res = (Integer.valueOf(months.get(index - 1))) + "月";
                    }
                } else if (months.size() == 2) {
                    if (index == 1 || index == 2) {
                        res = (Integer.valueOf(months.get(index - 1))) + "月";
                    }
                } else if (months.size() == 1) {
                    if (index == 1) {
                        res = (Integer.valueOf(months.get(index - 1))) + "月";
                    }
                }
                return res;
            }
        });

        //设置y轴的数据
        List<List<Float>> yValues = new ArrayList<>();
        List<Float> lateValues = new ArrayList<>();
        for (int i = 0; i < newDatas.size(); i++) {
            lateValues.add(Float.parseFloat(newDatas.get(i).getAbsent()));
        }
        yValues.add(lateValues);

        //颜色
        List<Integer> colours = new ArrayList<>();
        colours.add(Color.GREEN);

        //线的名字集合
        List<String> names = new ArrayList<>();
        names.add("旷到");

        //创建一条折线的图表
        lineChartManager.showLineChart(lateXValues, yValues.get(0), names.get(0), colours.get(0));

        //设置X轴最大值,最小值,标签数量
        lineChartManager.setXAxis(lateXValues.size(), 1f, lateXValues.size());

        lineChartManager.setDescription("");

        //设置Y轴最大值,最小值,标签数量
        lineChartManager.setYAxis(10, 0, 10);
    }

    /**
     * 更新旷到的曲线图数据
     *
     * @param newDatas
     */
    private void updateChartLateData(List<ClassAnalyInfo.DataBean> newDatas) {
        setLineChartLateData(newDatas);
        lineChart_kd.invalidate();
    }


    /**
     * 根据返回的时间格式2018-06来获取月份,不取月份前面的0
     */
    private String getMonth(String data) {
        String res = "";
        if (TextUtils.isEmpty(data)) {
            return res;
        } else {
            String[] split = data.split("-");
            if (split != null && split.length != 0) {
                //取出月份
                String month = split[1];
                if (month.startsWith("0")) {
                    //以0开头话
                    res = month.substring(1, month.length());
                } else {
                    //不以0开头
                    res = month;
                }
            }
            return res;
        }
    }


    /**
     * 时间选择器
     *
     * @param pos
     */
    private void showTimePicker(final int pos) {
        //比较时间差,必须大于等于2个月并且小于等于6个月
        PickerManager.showPickerByYeaerAndMonthAndDayByLimit(getContext(), new PickerManager.onSelectedListener() {
            @Override
            public void onTimeSelect(Date date, View v) {
                if (pos == 0) {

                    String chooseBeginDate = DateUtils.getTime(date, "yyyy-MM-dd");
                    //比较时间差,然后刷新页面数据
                    long end = DateUtils.getTime(enddate, "yyyy-MM-dd");
                    long start = DateUtils.getTime(chooseBeginDate, "yyyy-MM-dd");

                    //计算选择的开始和结束时间,转化为date格式
                    Date startDate = null;
                    Date endDate = null;
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    try {
                        startDate = sdf.parse(chooseBeginDate);
                        endDate = sdf.parse(enddate);
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }

                    if (end <= start) {
                        ToastUtils.showShort("选择的结束时间不能小于开始时间");
                        return;
                    } else if (DateUtils.getDiffMonth(startDate, endDate) < 2) {
                        //小于2个月
                        ToastUtils.showShort("选择的时间间隔不能小于2个月");
                        return;
                    } else if (DateUtils.getDiffMonth(startDate, endDate) > 6) {
                        //大于6个月
                        ToastUtils.showShort("选择的时间间隔不能超过6个月");
                        return;
                    } else {
                        begindate = DateUtils.getTime(date, "yyyy-MM-dd");

                        tvBeginTime.setText(DateUtils.getFmTime(begindate));

                        //更新柱状图的名称
                        tvBar.setText(getMonth(begindate) + "~" + getMonth(enddate) + "月份考勤数据汇总");
                        //刷新数据
                        http(BqaManager.PULLREFRESH);
                    }
                } else if (pos == 1) {
                    String chooseEndDate = DateUtils.getTime(date, "yyyy-MM-dd");
                    //比较时间差,然后刷新页面数据
                    long end = DateUtils.getTime(chooseEndDate, "yyyy-MM-dd");
                    long start = DateUtils.getTime(begindate, "yyyy-MM-dd");

                    //计算选择的开始和结束时间,转化为date格式
                    Date startDate = null;
                    Date endDate = null;
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    try {
                        startDate = sdf.parse(begindate);
                        endDate = sdf.parse(chooseEndDate);
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }

                    if (end <= start) {
                        ToastUtils.showShort("选择的结束时间不能小于开始时间");
                        return;
                    } else if (DateUtils.getDiffMonth(startDate, endDate) < 2) {
                        //小于2个月
                        ToastUtils.showShort("选择的时间间隔不能小于2个月");
                        return;
                    } else if (DateUtils.getDiffMonth(startDate, endDate) > 6) {
                        //大于6个月
                        ToastUtils.showShort("选择的时间间隔不能超过6个月");
                        return;
                    } else {
                        enddate = DateUtils.getTime(date, "yyyy-MM-dd");
                        tvEndTime.setText(DateUtils.getFmTime(enddate));

                        //更新柱状图的名称
                        tvBar.setText(getMonth(begindate) + "~" + getMonth(enddate) + "月份考勤数据汇总");
                        //刷新数据
                        http(BqaManager.PULLREFRESH);
                    }
                }
            }
        });
    }

    /**
     * 点击事件
     *
     * @param view
     */
    @Override
    public void onClick(View view) {
        int id = view.getId();
        if (id == R.id.tv_end_time) {
            //选择结束时间
            showTimePicker(1);
        } else if (id == R.id.tv_begin) {
            //选择开始时间
            showTimePicker(0);
        }
    }
}
